Skip to content
This repository has been archived by the owner on Dec 1, 2021. It is now read-only.

Added image reading function for runtime #577

Merged
merged 55 commits into from
Nov 26, 2019

Conversation

yoya
Copy link
Contributor

@yoya yoya commented Oct 30, 2019

Added image reading function for runtime.

Motivation and Context

In the runtime examples run.cpp,
I want to read the actual image, not the dummy random image.

Description

Added image reading function for runtime.

  Tensor Tensor_loadImage(std::string filename);

We can load images in npy format even if neither link external image library.
When linking libpng, PNG can be read.
If you link opencv, you can read the format that opencv can read.

How has this been tested?

  • reference (lmnet run.py)
$ cd blueoil/output_template/python
$ python run.py -m lib_x86.so -c meta.yaml -i raw_image.png
Output: (before post process)
[[1.0594523e-04 6.2350206e-05 3.2353133e-02 3.6062470e-03 1.2402927e-02
  2.3177502e-04 9.5100403e-01 8.7061970e-05 9.8417870e-05 4.8058930e-05]]
Output:
[[1.0594523e-04 6.2350206e-05 3.2353133e-02 3.6062470e-03 1.2402927e-02
  2.3177502e-04 9.5100403e-01 8.7061970e-05 9.8417870e-05 4.8058930e-05]]
save json: output/output.json
save image: output/images/raw_image.png
  • runtime (neither link image library)
$ cd blueoil/runtime
$ mkdir build ; cd build
$ DLK_LIB_DIR=`pwd`/../examples/dlk_lib/ cmake -DBUILD_SHARED_LIBS=ON ../
$ make install
$
$ cd ../examples
$ cp -R ../build/output/* ./
$ cmake .
$ make
$
$ ./a.out -i cat.npy -c meta.yaml
classes:
airplane
automobile
bird
cat
deer
dog
frog
horse
ship
truck
task: IMAGE.CLASSIFICATION
expected input shape:
1
32
32
3
Run
Results !
0.000105945
6.23502e-05
0.0323531
0.00360625
0.0124029
0.000231775
0.951004
8.7062e-05
9.84179e-05
4.80589e-05
  • runtime (with libpng)
$ cd ../build/
$ rm CMakeCache.txt
$ DLK_LIB_DIR=`pwd`/../examples/dlk_lib/ cmake -DBUILD_SHARED_LIBS=ON ../ -DUSE_LIBPNG=ON
$ make install
$
$ cd ../examples
$ cp -R ../build/output/* ./
$ rm CMakeCache.txt
$ cmake . -DUSE_LIBPNG=ON
$ make
$
$ ./a.out -i cat.png -c meta.yaml
classes:
airplane
automobile
bird
cat
deer
dog
frog
horse
ship
truck
task: IMAGE.CLASSIFICATION
expected input shape:
1
32
32
3
Run
Results !
0.000105945
6.23502e-05
0.0323531
0.00360625
0.0124029
0.000231775
0.951004
8.7062e-05
9.84179e-05
4.80589e-05
  • runtime (with opencv)
$ cd ../build/
$ rm CMakeCache.txt
$ DLK_LIB_DIR=`pwd`/../examples/dlk_lib/ cmake -DBUILD_SHARED_LIBS=ON ../ -DUSE_OPENCV=ON
$ make install
$
$ cd ../examples
$ cp -R ../build/output/* ./
$ rm CMakeCache.txt
$ cmake . -DUSE_OPENCV=ON
$ make
$
$ ./a.out -i cat.png -c meta.yaml
classes:
airplane
automobile
bird
cat
deer
dog
frog
horse
ship
truck
task: IMAGE.CLASSIFICATION
expected input shape:
1
32
32
3
Run
Results !
0.000105945
6.23502e-05
0.0323531
0.00360625
0.0124029
0.000231775
0.951004
8.7062e-05
9.84179e-05
4.80589e-05

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature / Optimization (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

yoya and others added 30 commits July 16, 2019 22:01
- command line: cmake => cmake .
- sample path: /home/.../git/ => <repost_dir>
(mainly from tkng/emscripten branch.)

- FormatYoloV2, NMS,
- softmax, sigmoid, CalcIoU
- ConvertBboxCoordinate, PerImageStandardization
- etc. required Tensor functions.
(little modified examples/run.cpp, fitting to 80-chara width)
…ries(opencv, libpng) installation situation.

But, image readers(png,npy) not implemented yet.
delete randomImage (debug function)
replace it to GLOB & REMOVE_ITEM. for Cmake 3.5
@blueoil-butler blueoil-butler bot added the CI: auto-run Run CI automatically label Oct 30, 2019
@yoya yoya changed the title Dev/runtime/readimage Added image reading function for runtime Oct 30, 2019
@iizukak iizukak requested a review from tkng November 20, 2019 02:01
Copy link
Contributor

@tkng tkng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you remove the binary file runtime/examples/dlk_lib/libdlk_x86.a?

@tkng
Copy link
Contributor

tkng commented Nov 22, 2019

Other than the small comments above, LGTM.

Copy link
Contributor

@tkng tkng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution, other than commented points, looks good to me.

yoya and others added 3 commits November 26, 2019 15:10
- for (a ; b ;c) => for (a; b; c)
- change example executable name. a.out => run
- modify bad style of parenthesis.
Copy link
Contributor

@tkng tkng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution! I'll merge the PR after unit test passed.

@tkng tkng merged commit c7ea652 into blue-oil:master Nov 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
CI: auto-run Run CI automatically
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants